import 'package:architecture/os_size.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:study_demo/widgets/yz_text.dart';

import 'test_word_speed_controller.dart';

class TestWordSpeedPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return GetX<TestWordSpeedController>(
        init: TestWordSpeedController(),
        builder: (controller) {
          return Scaffold(
              appBar: AppBar(
                title: Text('打字测速'),
              ),
              body: Container(
                margin: EdgeInsets.symmetric(horizontal: 15),
                child: Column(
                  children: [
                    Text(controller.timeInfo,
                        style: TextStyle(color: Colors.red, fontSize: 42)),
                    Column(
                      crossAxisAlignment: CrossAxisAlignment.end,
                      children: [
                        Container(
                          height: 200,
                          width: windowWidth * 0.7,
                          margin: EdgeInsets.only(top: 10),
                          color: Color(0xffF4F0EF),
                          padding: EdgeInsets.only(left: 10),
                          child: IgnorePointer(
                            ignoring: controller.timeInfo == '00:00',
                            child: YzText(
                              controller: controller.descController,
                              text: '',
                              width: 0,
                              maxLine: 8,
                              onChanged: (value) {},
                            ),
                          ),
                        ),
                        Text(
                          '耗时：' +
                              (60 - controller.num.value).toString() +
                              's  字数：' +
                              controller.textNum.value.toString(),
                          style:
                              TextStyle(color: Colors.redAccent, fontSize: 21),
                        ),
                      ],
                    ),
                    SizedBox(
                      height: 15,
                    ),
                    Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        Container(
                            width: 200,
                            child: TextButton(
                                style: TextButton.styleFrom(
                                    backgroundColor: Colors.redAccent,
                                    padding: const EdgeInsets.symmetric(
                                        horizontal: 8, vertical: 0)),
                                onPressed: () {
                                  controller.test();
                                },
                                child: Text(
                                  '测试',
                                  style: TextStyle(
                                      color: Colors.white, fontSize: 17),
                                )))
                      ],
                    )
                  ],
                ),
              ));
        });
  }
}
